package spring.cloud.tasks.api.service;

import org.apache.curator.framework.CuratorFramework;
import spring.cloud.tasks.api.domain.NameSpace;
import spring.cloud.tasks.api.domain.NameSpaceClient;
import spring.cloud.tasks.api.domain.NameSpaceConfiguration;
import spring.cloud.tasks.api.domain.ZooKeeperCluster;
import spring.cloud.tasks.api.zookeeper.ZooKeeper;

import java.util.List;

public interface ZooKeeperService {

    void notifyRefresh() throws RuntimeException;


    NameSpaceClient connectByNameSpace(String nameSpace);


    NameSpaceConfiguration getNameSpaceConfigurationByNameSpace(String nameSpace);

    List<NameSpaceConfiguration> findConfigsByZkCluster(ZooKeeperCluster zooKeeperCluster);

    ZooKeeper connectOnly(String zkAddr, String namespace) throws RuntimeException;


    ZooKeeperCluster getZooKeeperCluster(String zooKeeperClusterKey);

    void createZooKeeperClusterInfo(String zooKeeperClusterKey, String alias, String connectString, String description)
            throws RuntimeException;

    void updateZkCluster(String zooKeeperClusterKey, String connectString, String description)
            throws RuntimeException;

    List<ZooKeeperCluster> getZooKeeperClusterList();

    List<ZooKeeperCluster> getOnlineZooKeeperClusterList();

    int domainCount(String zooKeeperClusterKey);

    boolean nameSpaceIsCorrect(String nameSpace, CuratorFramework curatorFramework) throws RuntimeException;

    List<String> getOnlineNameSpaceList() throws RuntimeException;


    /**
     * Create Namespace.
     */
    void createNameSpace(NameSpace nameSpace) throws RuntimeException;


    /**
     * Get namespace by key.
     */
    NameSpace getNameSpace(String nameSpace) throws RuntimeException;


    ZooKeeper getZooKeeper(String nameSpace) throws RuntimeException;

    void refreshRegistryCenterForNamespace(String zooKeeperClusterKey, String nameSpace);

    void deleteZooKeeperClusterInfo(String zooKeeperClusterKey) throws RuntimeException;
}
